


import { registerClass } from "../../../cfw/tools/class_decorator";
import BaseAd from "../../core/base/BaseAd";
/**
 * public enum BannerLayout {
    TOP_MID,//上中
    BOTTOM_MID,//下中
 }
 */
@registerClass('CSJBannerAd')
export default class CSJBannerAd extends BaseAd {
    hide(): void {
        throw new Error("Method not implemented.");
    }
    load(): void {
        throw new Error("Method not implemented.");
    }
    show(): void {
        throw new Error("Method not implemented.");
    }


    create() {
        if (!this.ad) {
            this.ad = this.sdk.createBannerAd({
                adUnitId: this.adUnitID,
                layout: 1,
                width: 300,
                height: 100
            })
            this.ad.onLoad(this.onLoad.bind(this))
            this.ad.onError(this.onError.bind(this))
        }

        // this.instance.onResize(this.onResize.bind(this))
        this.ad.load()
    }
    destroy(): void {
       
        if (this.ad) {
            console.log(' banner destroy', this.ad)
            this.ad.offLoad(this.getFunc(this.onLoad))
            this.ad.offError(this.getFunc(this.onError))
            this.ad.destroy();
            this.ad = null;
        }
    }

}
